import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JButton;
import javax.swing.SwingConstants;

import java.awt.Color;
import java.awt.Button;
import javax.swing.JLabel;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;


public class PatientPanel extends JPanel{
	private JButton btnViewHistory;
	private JButton btnViewApp;
	private JButton btnMakeApp;
	private JButton btnViewInvoice;

	private class ButtonListen implements ActionListener{

		
		public void actionPerformed(ActionEvent e) {
			if(e.getSource().equals(btnViewHistory)){
				btnViewHistory.getParent().firePropertyChange("viewHistory", 0, 1);
			}
			else if(e.getSource().equals(btnMakeApp)){
				btnMakeApp.getParent().firePropertyChange("makeAppointment", 0, 1);
			}
			else if(e.getSource().equals(btnViewInvoice)){
				btnViewInvoice.getParent().firePropertyChange("viewInvoice", 0, 1);
			}
			else if(e.getSource().equals(btnViewApp)){
				btnViewApp.getParent().firePropertyChange("viewSchedule", 0, 1);
			}
			
		}
		
	}
	
	public PatientPanel() {
		setBackground(new Color(240, 240, 240));
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		btnViewHistory = new JButton("View History");
		springLayout.putConstraint(SpringLayout.NORTH, btnViewHistory, 157, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, btnViewHistory, 10, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, btnViewHistory, 140, SpringLayout.WEST, this);
		btnViewHistory.addActionListener(new ButtonListen());
		add(btnViewHistory);
		
		btnMakeApp = new JButton("Make Appointment");
		springLayout.putConstraint(SpringLayout.WEST, btnMakeApp, 10, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, btnMakeApp, -6, SpringLayout.NORTH, btnViewHistory);
		springLayout.putConstraint(SpringLayout.EAST, btnMakeApp, 0, SpringLayout.EAST, btnViewHistory);
		btnMakeApp.addActionListener(new ButtonListen());
		add(btnMakeApp);
		
		btnViewApp = new JButton("View Appointments");
		springLayout.putConstraint(SpringLayout.NORTH, btnMakeApp, 6, SpringLayout.SOUTH, btnViewApp);
		springLayout.putConstraint(SpringLayout.EAST, btnViewApp, 140, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.WEST, btnViewApp, 10, SpringLayout.WEST, this);
		btnViewApp.addActionListener(new ButtonListen());
		add(btnViewApp);
		
		
		
		JLabel lblAdministrative = new JLabel("Patient");
		springLayout.putConstraint(SpringLayout.EAST, lblAdministrative, 139, SpringLayout.WEST, this);
		lblAdministrative.setFont(new Font("Pristina", Font.ITALIC, 18));
		lblAdministrative.setHorizontalAlignment(SwingConstants.CENTER);
		springLayout.putConstraint(SpringLayout.NORTH,
				lblAdministrative, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST,
				lblAdministrative, 10, SpringLayout.WEST, this);
		add(lblAdministrative);
		
		JLabel lblMenu = new JLabel("Menu");
		springLayout.putConstraint(SpringLayout.NORTH, btnViewApp, 38, SpringLayout.SOUTH, lblMenu);
		springLayout.putConstraint(SpringLayout.SOUTH, btnViewApp, 61, SpringLayout.SOUTH, lblMenu);
		springLayout.putConstraint(SpringLayout.NORTH, lblMenu, 7, SpringLayout.SOUTH, lblAdministrative);
		springLayout.putConstraint(SpringLayout.EAST, lblMenu, 140, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.WEST,
				lblMenu, 10, SpringLayout.WEST, this);
		lblMenu.setFont(new Font("Pristina", Font.ITALIC, 18));
		lblMenu.setHorizontalAlignment(SwingConstants.CENTER);
		add(lblMenu);
		
		btnViewInvoice = new JButton("View Invoice");
		springLayout.putConstraint(SpringLayout.NORTH, btnViewInvoice, 6, SpringLayout.SOUTH, btnViewHistory);
		springLayout.putConstraint(SpringLayout.WEST, btnViewInvoice, 10, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.EAST, btnViewInvoice, 0, SpringLayout.EAST, btnViewHistory);
		add(btnViewInvoice);
		btnViewInvoice.addActionListener(new ButtonListen());
		
		
	}
}
